import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: [
      {
        find: "@",
        replacement: resolve(__dirname, "./src"),
      },
      {
        find: "assets",
        replacement: resolve(__dirname, "./src/assets"),
      },
    ],
  },
  css: {
    preprocessorOptions: {
      css: {
        // 预处理器配置项
        preprocessorOptions: {
          less: {
            math: "always",
            globalVars: {
              fontSizeNormal: "16px",
              baseBgColor: "#f9f9f9",
            },
          },
        },
      },
    },
  },
  server: {
    // 配置服务器代理，实现跨域
    // https: true,
    port:3001,
    proxy: {
      "/schoolServer": {
        target: "http://127.0.0.1:8099/",
        changeOrigin: true,
        //去掉接口中的 '/api'以便和后端接口匹配
        // rewrite: (path) => path.replace(/^\/api/, ""),
      }
    },
  },
});
